﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddCustomerPosts.aspx.cs" Inherits="msBsc.WebUi.ShpMana.AddCustomerPosts" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>添加地接客推荐信息</title>
    <link href="/themes/wStyle1/css/sLayout.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sHead.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sFoot.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/usermenu.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/from.css" rel="stylesheet" />
    <link href="/jqPlugin/hdfu/hdfu.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/Seller/sReleaseForum.css" rel="stylesheet" />
    <link href="/jqPlugin/kindeditor/themes/default/default.css" type="text/css" rel="stylesheet" />
    <style>
        .selArea {
            width: 100px;
            height: 30px;
            line-height: 30px;
            margin-right: 10px;
            font-family: 微软雅黑;
            font-size: 16px;
            color: #808080;
        }
    </style>
</head>
<body>
    <div class="wf_all">
        <div class="main-container">
            <div class="main-Info">
                <div class="main-horizontal">
                    <div class="r_row">
                        <span class="control-span">标题<span class="required">*</span></span><div class="controls">
                            <input type="text" id="title" class="input titleInput" />
                            <span id="titleMessage" class="help-inline"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">地区<span class="required">*</span></span>
                        <div class="controls">
                            <select class="selArea" id="selCountry">
                                <option value="0">请选择</option>
                                <option value="DF6723BE-A25C-4F77-BB49-A1662D3E6F2A">中国</option>
                                <option value="453370FE-8295-41EC-A41C-B6F650AD1B4C">亚洲</option>
                                <option value="927D5F28-C4FB-46A9-940C-B07DF0A04018">北美洲</option>
                                <option value="1FEAF456-7C76-41C8-A3D0-F9C12415A736">南美洲</option>
                                <option value="4E2B4524-E9CB-4E20-9224-E58EB636D1C7">非洲</option>
                                <option value="67FA6A8D-951C-4B53-AE1E-70DCB97E11DE">欧洲</option>
                                <option value="0B772F3D-D8F8-42E3-9019-81FE6F772236">大洋洲</option>
                            </select>
                            <select class="selArea" id="selCity">
                                <option value="0">请选择</option>
                            </select>
                            <xmp id="country_city_list" style="display: none">
                                <option value="0">请选择</option>
            {{#for(var i=0,len=d.rows.length;i < len;i++){ }}
                   <option value="{{d.rows[i].COUNTRY_CITY_ID}}">{{d.rows[i].COUNTRY_CITY_NME}}</option>
            {{#} }}        
            </xmp>
                            <select class="selArea" id="selDestination">
                                <option value="0">请选择</option>
                            </select>
                            <xmp id="city_des_list" style="display: none">
                                    <option value="0">请选择</option>
            {{#for(var i=0,len=d.rows.length;i < len;i++){ }}
                   <option value="{{d.rows[i].COUNTRY_CITY_ID}}">{{d.rows[i].COUNTRY_CITY_NME}}</option>
            {{#} }}
            </xmp>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">关键字<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" id="txtKeyword" class="input titleInput" />
                            <span id="keywordMessage" class="help-inline"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">推荐内容<span class="required">*</span></span>
                        <div class="controls">
                            <textarea name="content" id="forumInfo"></textarea>
                            <span id="forumInfoMessage" class="help-inline"></span>
                        </div>
                    </div>
                    <div style="text-align: center; margin-top: 20px;">
                        <input type="button" id="published" class="releaseBtn" style="margin-right: 20px;" value="写好了,发布" />
                        <%--<input type="button" id="published" class="releaseBtn" style="margin-right: 20px;" onclick="javascript: doSaveSet(); return false;" value="写好了,发布" />--%>
                        <input type="button" class="previewBtn" onclick="previewForum()" value="预览一下" />
                    </div>
                </div>
            </div>
            <div class="ui-mask"></div>
            <div id="altContent">
                <div class="titleName" id="titleName">ds</div>
                <div id="forumContent"></div>
                <span class="close" id="colseHeadPhoto">&times;</span>
            </div>
        </div>
        <!--start JS引用-->
        <script src="/jqPlugin/js/jquery-1.8.3.min.js"></script>
        <script src="/jqPlugin/js/jBase.js"></script>
        <script src="/jqPlugin/js/jBPage.js"></script>
        <script src="/jqPlugin/js/laytpl.js"></script>
        <script src='/??jqPlugin/kindeditor/kindeditor.js,jqPlugin/kindeditor/lang/zh_CN.js'
            type='text/javascript'></script>
        <script src="/themes/wStyle1/js/comm/VerifyJs.js"></script>

        <script src="/jqPlugin/SelectSimu/js/SelectSimu.js"></script>
        <script src="/themes/wStyle1/js/comm/jsLayout.js"></script>
        <!--end JS引用-->
        <script type="text/javascript">
            function SetAreaInfo() {
                $("#selCountry").change(function () {
                    $("#selCity").html("<option value='0'>请选择</option>");
                    $("#selDestination").html("<option value='0'>请选择</option>");
                    var _opartParam = new jsonRow();
                    _opartParam.AddCell("countryId", $("#selCountry").val());
                    _opartParam.AddCell("cityId", $("#selCity").val());
                    _opartParam.AddCell("ACTION", "changeArea");
                    ajaxComm(_opartParam);
                })

                $("#selCity").change(function () {
                    $("#selDestination").html("<option value='0'>请选择</option>");
                    var _opartParam = new jsonRow();
                    _opartParam.AddCell("cityId", $("#selCity").val());
                    _opartParam.AddCell("ACTION", "changeArea");
                    ajaxComm(_opartParam);
                })
            }
            SetAreaInfo();


            K = KindEditor;
            //        K.DEBUG = true;
            K.basePath = K.options.basePath = '/jqPlugin/kindeditor/';
            K.options.themesPath = K.options.basePath + 'themes/';
            K.options.langPath = K.options.basePath + 'lang/';
            K.options.pluginsPath = K.options.basePath + 'plugins/';
            function getfilequery() {
                return "&ParentId=" + "&FileId=" + ""
                                        + "&RelId=" + ""
                                        + "&rType1=" + "0"
                                        + "&rType2=" + "0";
            };

            var editorContend;
            function SetEditHtml(_sHtml) {
                scontenthtml = _sHtml;
            };
            var scontenthtml = '';
            $(window).load(function () {

                editorContend = K.create('#forumInfo', {
                    allowFileManager: true,
                    resizeType: 0,
                    allowPreviewEmoticons: true,
                    allowImageUpload: false,
                    loadStyleMode: false,
                    designMode: true,
                    afterCreate: function () {

                    }
                });
                editorContend.fileManagerJson = '/pgajax.axd?F_MANA=1&rType1=0&rType2=0&COOKATHID=' + (typeof (cookesc) == "undefined" ? "" : cookesc)
                                        + "&fType=" + "mana";
                editorContend.uploadJson = '/pgajax.axd?F_UPLOAD=1&blSave=1&COOKATHID=' + (typeof (cookesc) == "undefined" ? "" : cookesc)
                                        + "&fType=" + "mana"
                                        + getfilequery();
                editorContend.sync("forumInfo");
                editorContend.html(scontenthtml);

                $.ploadFile("layer", function (script, textStatus) {
                    //                layer.load('加载中'); 
                });
            });

            function doBoundContent(_shopurl) {
                if (_shopurl != null && _shopurl != undefined && _shopurl != '') {
                    jQuery.loadHtml(_shopurl).done(function (_rethtml) {
                        var tpl = HtmlUtil.htmlDecode(_rethtml);
                        scontenthtml = tpl;
                        editorContend && editorContend.html(tpl);
                    });
                }
            };

            function doSaveSet() {
                var loadi = layer.load('正在保存中…');
                try {
                    function closeload() { layer.close(loadi); }
                    var _jsParam = new jsonRow();
                    _jsParam.AddCell("ACTION", "doSaveSet");
                    //获取数据
                    var _jsPost = new jsonRow();
                    _jsPost.AddCell("TEMPLATE_HTML", editorContend.html());
                    _jsPost.AddCell("TEMPLATE_URL", $("#txtTempUrl").val());

                    ajaxComm(_jsParam, _jsPost, closeload);
                }
                catch (err) {
                    layer.close(loadi);
                }
            };

            (function () {
                /*start 预览关闭按钮*/
                $("#colseHeadPhoto").live("click", function () {
                    cancelPreview();
                });
                /*end 预览关闭按钮*/

                //创建编辑器
                //createEditor();
                //发布按钮
                $("#published").click(function () {
                    btnDo("published");
                });


            })();
            function createEditor() {
                KindEditor.ready(function (k) {
                    k.create('textarea[name="content"]', {
                        resizeType: 0,
                        width: "100%",
                        height: "200px",
                        cssPath: '/jqPlugin/kindeditor/plugins/code/prettify.css',
                        uploadJson: '/Static/assets/kindeditor-4.1.10/asp.net/upload_json.ashx',
                        fileManagerJson: '/Static/assets/kindeditor-4.1.10/asp.net/file_manager_json.ashx',
                        allowFileManager: true,
                        afterCreate: function () { this.sync(); },
                        afterBlur: function () { this.sync(); }
                    });
                });
            }

            var pIndex = 1;
            var pageSize = 11;
            function btnDo(sEbtn) {
                GtGrid1Action = sEbtn;
                var opart = GetGtParam();
                if (opart != null) {
                    ajaxComm(opart);
                }
            };

            //执行AJAX调用时获取参数
            function GetGtParam() {
                //论坛标题
                var forumTitle = $("#title").val();
                if (!vfcTitleName(forumTitle)) {
                    return null;
                }

                var countryId = $("#selCountry").val();
                var cityId = $("#selCity").val();
                var destinationId = $("#selDestination").val();
                if (countryId == "0" || cityId == "0") {
                    alert("请选择地区");
                    return null;
                }
                var custKeyword = $("#txtKeyword").val();
                if (IsNull(custKeyword)) {
                    alert("请输入关键字，让你的推荐更易被查找");
                    return null;
                }

                if (custKeyword.length > 125) {
                    alert("关键字过长，不能超过120个字符");
                    return null;
                }

                //论坛内容
                //var forumInfo = $("#forumInfo").val();
                var forumInfo = editorContend.html();
                if (!vfcForumInfo(forumInfo)) {
                    return null;
                }


                var _jsParam = new jsonRow();
                _jsParam.AddCell("countryId", countryId);
                _jsParam.AddCell("cityId", cityId);
                _jsParam.AddCell("desId", $("#selDestination").val());
                _jsParam.AddCell("custKeyword", custKeyword);
                _jsParam.AddCell("forumTitle", forumTitle);
                _jsParam.AddCell("forumInfo", forumInfo);
                _jsParam.AddCell("djackId", GetQueryStr("djkId"));
                _jsParam.AddCell("ACTION", GtGrid1Action);
                return _jsParam;
            };

            /*预览论坛*/
            function previewForum() {
                var titleName = $("#title").val();
                var html = editorContend.html();
                $("#forumContent").html(html);
                $("#titleName").text(titleName);
                $("#altContent").show();
                $(".ui-mask").show();

            }

            /*取消预览*/
            function cancelPreview() {
                $("#titleName").html("");
                $("#forumContent").html("");
                $("#altContent").hide();
                $(".ui-mask").hide();
            }

            /*
         * 验证论坛标题
         * titleName 论坛标题
        */
            function vfcTitleName(titleName) {
                if (IsNull(titleName)) {
                    alert("论坛标题不能为空");
                    return false;
                }
                if (!islength(titleName, 0, 50)) {
                    alert("论坛标题最大长度为40个字符");
                    return false;
                }
                return true;
            }

            /*
             * 验证论坛内容
             * forumInfo 论坛内容
            */
            function vfcForumInfo(forumInfo) {
                if (IsNull(forumInfo)) {
                    alert("*论坛内容不能为空");
                    return false;
                }
                return true;
            }
        </script>
    </div>
</body>
</html>
